package Member_Message;

import java.io.*;

class Postgraduate extends Student {
    String direction;
    String tutor;
    Postgraduate(){
        super();
        this.direction = "direction";
        this.tutor = "tutor";
    }
    Postgraduate(String name, String address, int telephonenumber, String email, int grade,String direction, String tutor){
        super(name, address, telephonenumber, email,grade);
        this.direction = direction;
        this.tutor = tutor;
    }
    @Override
    public String toString(){
        return "Name: " + name + "  class: Postgraduate";
    }
}

class Faculty extends Employee {
    double worktime;
    String level;

    Faculty(){
        super();
        this.worktime = -1;
        this.level = "level";
    }
    Faculty(String name, String address, int telephonenumber, String email, String office,
            int salary, int year, int month, int day,int worktime, String level){
        super(name, address, telephonenumber, email,office,salary,year, month ,day);
        this.worktime = worktime;
        this.level = level;
    }
    @Override
    public String toString(){
        return "Name: " + name + "  class: Faclty";
    }
}

class Staff extends Employee {
    String duty;

    Staff(){
        super();
        this.duty = "duty";
    }

    Staff(String name, String address, int telephonenumber, String email, String office,
          int salary, String duty,int year, int month, int day){
        super(name, address, telephonenumber, email,office,salary,year,month,day);
        this.duty = duty;
    }
    @Override
    public String toString(){
        return "Name: " + name + "  class: Staff";
    }
}

class Employee extends Person {
    String office;
    int salary;
    My_Date whenemploy;

    Employee(){
        super();
        this.office = "office";
        this.salary = -1;
        whenemploy = new My_Date();
    }

    Employee(String name, String address, int telephonenumber, String email, String office,
             int salary, int year, int month, int day){
        super(name, address, telephonenumber, email);
        this.office = office;
        this.salary = salary;
        whenemploy = new My_Date(year ,month, day);
    }
    @Override
    public String toString(){
        return "Name: " + name + "  class: Emloyee";
    }
}

class Student extends Person {
    int grade;

    Student(){
        super();
        this.grade = 0;
    }
    Student(String name, String address, int telephonenumber, String email, int grade){
        super(name, address, telephonenumber, email);
        this.grade = grade;
    }
    @Override
    public String toString(){
        return "Name: " + name + "  class: Student";
    }
}

class Person implements Serializable {
    String name;
    String address;
    int telephonenumber;
    String email;

    Person(){
        this.name = "name";
        this.address = "address";
        this.telephonenumber = 0;
        this.email = "email";
    }
    Person(String name, String address, int telephonenumber, String email){
        this.name = name;
        this.address = address;
        this.telephonenumber = telephonenumber;
        this.email = email;
    }
    public void writeToFile(File f) throws IOException {
        try(ObjectOutputStream objectOutputStream =
                    new ObjectOutputStream(new FileOutputStream(f, false))){
            objectOutputStream.writeObject(this);
        }
    }
    @Override
    public String toString(){
        return "Name: " + name + "  class: Person";
    }
}

